package com.yue.rpc.remoting.transport.netty.client;

import com.yue.rpc.remoting.dto.RpcMessage;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
/**
 * @Author zhangqiyue
 * @Description
 * @Date 2023/3/6 15:24
 */
public class NettyClientHandler extends SimpleChannelInboundHandler<Object> {
    private NettyClientListener listener;

    public NettyClientHandler(NettyClientListener listener) {
        this.listener = listener;
    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Object msg)
            throws Exception {
        if (msg != null) {
            if (msg instanceof RpcMessage) {
                listener.channelRead((RpcMessage) msg);
            }
        }

    }

}